package com.yanqu.road.logic.pb;

import com.yanqu.road.entity.recharge.RechargeGain;
import com.yanqu.road.entity.recharge.RechargeMallTimes;
import com.yanqu.road.pb.recharge.RechargeProto;

import java.util.List;

public class RechargePb {

	public static RechargeProto.RechargeGainTempMsg.Builder parseRechargeGainTempMsg(RechargeGain rechargeGain) {
		if(null == rechargeGain){
			return null;
		}
		RechargeProto.RechargeGainTempMsg.Builder msg = RechargeProto.RechargeGainTempMsg.newBuilder();
		msg.setMallId(rechargeGain.getMallId());
		msg.setState(rechargeGain.getState());

		return msg;
	}

	public static RechargeProto.RechargeGainListMsg.Builder parseRechargeGainListMsg(List<RechargeGain> rechargeGainList) {
		RechargeProto.RechargeGainListMsg.Builder listMsg = RechargeProto.RechargeGainListMsg.newBuilder();
		if(null != rechargeGainList) {
			for (RechargeGain rechargeGain : rechargeGainList) {
				RechargeProto.RechargeGainTempMsg.Builder msg = parseRechargeGainTempMsg(rechargeGain);
				if (null != msg) {
					listMsg.addDataList(msg);
				}
			}
		}
		return listMsg;
	}

	public static RechargeProto.RechargeTimesListMsg.Builder parseRechargeTimesListMsg(List<RechargeMallTimes> rechargeTimesList) {
		RechargeProto.RechargeTimesListMsg.Builder listMsg = RechargeProto.RechargeTimesListMsg.newBuilder();
		if(null != rechargeTimesList) {
			for (RechargeMallTimes rechargeTimes : rechargeTimesList) {
				RechargeProto.RechargeTimesTemp.Builder msg = parseRechargeTimesTempMsg(rechargeTimes);
				if (null != msg) {
					listMsg.addDataList(msg);
				}
			}
		}
		return listMsg;
	}

	private static RechargeProto.RechargeTimesTemp.Builder parseRechargeTimesTempMsg(RechargeMallTimes rechargeTimes) {
		if(null == rechargeTimes){
			return null;
		}
		RechargeProto.RechargeTimesTemp.Builder msg = RechargeProto.RechargeTimesTemp.newBuilder();
		msg.setMallId(rechargeTimes.getMallId());
		msg.setSrc(rechargeTimes.getSrc());
		msg.setTimes(rechargeTimes.getTimes());
		return msg;
	}

	/**
	* 描述：转充值详情msg
	* 作者：zrq
	* 时间：2021/12/30
	* 参数：
	最近充值时间
	* 返回值：msg
	**/
	public static RechargeProto.RechargeDetailMsg.Builder parseRechargeDetailMsg(long lastRechargeTime){
		RechargeProto.RechargeDetailMsg.Builder msg = RechargeProto.RechargeDetailMsg.newBuilder();
		msg.setLastRechargeTime(lastRechargeTime);
		return msg;
	}
}
